import 'package:flutter/material.dart';

class AnimationDemo extends StatefulWidget {
  const AnimationDemo({super.key});

  @override
  State<AnimationDemo> createState() => _AnimationDemoState();
}

class _AnimationDemoState extends State<AnimationDemo> {
  bool flag = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Title")),
      body: Center(
        child: AnimatedContainer(
          duration: Duration(milliseconds: 250),
          width: flag ? 300 : 200,
          height: flag ? 300 : 200,
          color: Colors.red,
          transform: flag ? Matrix4.translationValues(0, 0, 0) : Matrix4.translationValues(100, 0, 0),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
      ),
    );
  }
}
